import request from '@/config/axios'

// 数据配置 VO
export interface ScheduledVO {
  id: number // id
  newName: string // 新名称
  oldName: string // 旧名称
  time: number // 间隔时间
  status: string // 状态
  writeString: string // 文本
  dictType: string // 数据字典类型
  pid: number // 父ID
}

// 数据配置 API
export const ScheduledApi = {
  // 查询数据配置列表
  getScheduledList: async (params) => {
    return await request.get({ url: `/wms/scheduled/list`, params })
  },

  // 查询数据配置详情
  getScheduled: async (id: number) => {
    return await request.get({ url: `/wms/scheduled/get?id=` + id })
  },

  // 新增数据配置
  createScheduled: async (data: ScheduledVO) => {
    return await request.post({ url: `/wms/scheduled/create`, data })
  },

  // 修改数据配置
  updateScheduled: async (data: ScheduledVO) => {
    return await request.put({ url: `/wms/scheduled/update`, data })
  },

  // 删除数据配置
  deleteScheduled: async (id: number) => {
    return await request.delete({ url: `/wms/scheduled/delete?id=` + id })
  },

  // 导出数据配置 Excel
  exportScheduled: async (params) => {
    return await request.download({ url: `/wms/scheduled/export-excel`, params })
  },
  getDictData: async (pid: number) => {
    return await request.get({ url: `/wms/scheduled/getDictData?pid=` + pid })
  },
  generate: async (id: number) => {
    return await request.get({ url: `/wms/scheduled/generate?id=` + id })
  },
  close: async (id: number) => {
    return await request.get({ url: `/wms/scheduled/close?id=` + id })
  },
}
